package gohttp

import (
	"dgo/goutils/httpfs"
	"net/http"
)

func StartWebRoot(pattern string, rootPath string) {
	Handle(pattern, http.StripPrefix(pattern, http.FileServer(http.Dir(rootPath))))
}

func StartDefaultWebRoot() {
	StartWebRoot("/", "webroot/")
}

/*
*

	lsttype :
	  0: html, 1:json
*/
func StartHandleFileServ(pattern, path string, lsttype int, lstfiles bool) {
	fserv := httpfs.FileServer(http.Dir(path), lsttype, func(w http.ResponseWriter, r *http.Request) bool {
		return true
	})
	fserv.ListFiles = lstfiles
	Handle(pattern, http.StripPrefix(pattern, fserv))
}
